package com.miao.test.common.enums;

/**
 * @Auther: miaoguoxin
 * @Date: 2021/2/25 17:29
 * @Description:
 */
public enum MessageType {
    UNKNOWN(0, "未知"),
    REQ(1, "请求"),
    RES(2, "响应"),
    ;

    private int code;

    private String value;

    MessageType(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static MessageType getByCode(int code) {
        for (MessageType e : MessageType.values()) {
            if (e.getCode() == code) {
                return e;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }
}
